/********************************************/
  // Creation History
  // --------------------------------------------------------------
  //	Company:			HTHK
  //	NAME:				GroupSearch.java
  //    Title   :			find Group Records, return one or more records
  //	FUNCTION:
  //	BY:				Poly Li
  //	DATE:				14/01/2004
  // --------------------------------------------------------------
/*********************************************/
// Copyright (c) 2002 HTHK

package tss.group;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;

import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;

import tss.common.DBServlet2;

/**
 * A Class class.
 * <P>
 * @author HTHK
 */
public class GroupSearch
  extends DBServlet2 {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
      //New A Job
      GroupBean group = GroupProcess.createBean();

      //Get search condition
     group.setGroup_name(request.getParameter("group_name"));

	  //Get the results
      GroupBean[] groups = GroupProcess.find(this.getConnection(),group);
      //Find nothing
      if (groups==null || groups.length==0)
      {
          message.setMessage("No record, please input another criteria.");
          return "tss/group/GroupSearch.jsp";
      }
      //Find a record
      else if (groups.length==1)
      {
          request.setAttribute("groups",groups[0]);
          return "tss/group/Group.jsp?formAction=Update";
      }
      //find more than one records
      else
      {
          request.setAttribute("groups",groups);
          return "tss/group/GroupList.jsp";
      }
  }
}


